package com.yxcz.serviceImpl;

import java.util.ArrayList;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.yxcz.dao.CustomerDAO;
import com.yxcz.service.CustomerService;
import com.yxcz.model.Customer;

@Service
public class CustomerServiceImpl implements CustomerService {
	
	@Resource
	private CustomerDAO customerDAO;


	
	/*@Override
	public void addAll(String[][] suppliers) throws Exception {
		
		
		
	}*/


	@Override
	public ArrayList<Customer> list() {
	
		return customerDAO.list();
	}



	@Override
	public Customer find(Integer id) {
	   return customerDAO.find(id);
	   }



	@Override
	public void delete(Integer id) {
		customerDAO.delete(customerDAO.find(id));
		
	}



	@Override
	public void add(Customer customer) throws Exception {
		customerDAO.add(customer);
	}



	@Override
	public void update(Customer customer) {
	customerDAO.save(customer);
		
	}



	@Override
	public void addAll(String[][] customers) throws Exception {
		
		for (String[] string : customers) {
			Customer customer = new Customer();
			customer.setCompanyName(string[0]);
			customer.setCompanyShortName(string[1]);
			customer.setIdnumber(string[2]);
			customer.setPayType(string[3]);
			customer.setAddress(string[4]);
			customer.setSalesman(string[5]);
			customer.setContacts(string[6]);
			customer.setEmail(string[7]);
			customer.setPhone(string[8]);
			customer.setTelephone(string[9]);
			customer.setQq(string[10]);
			customer.setOther(string[11]);
			customer.setFax(string[12]);
			customerDAO.add(customer);
			
		}
		
	}





}
